Skip to content

Update sum-tree hashing to match the new spec#34

Merged
b3y0urs3lf merged 8 commits intomainfrom
issue-29
Nov 19, 2025
Merged

Update sum-tree hashing to match the new spec#34
b3y0urs3lf merged 8 commits intomainfrom
issue-29

Conversation

@martti007
Copy link
Copy Markdown
Contributor

No description provided.

@martti007 martti007 linked an issue Nov 7, 2025 that may be closed by this pull request
Base automatically changed from issue-30 to main November 11, 2025 06:16
@MastaP MastaP assigned martti007 and unassigned MastaP Nov 11, 2025
@MastaP MastaP requested review from MastaP and Copilot November 11, 2025 14:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the sum-tree hashing implementation to align with a new specification, simplifying the API and improving code maintainability.

Key Changes:

  • Refactored SparseMerkleSumTreeRootNode to directly expose hash and value methods instead of returning a Root wrapper object
  • Simplified SparseMerkleSumTreePathStep by removing the nested Branch class and flattening the structure with direct data and value fields
  • Updated hashing algorithm in FinalizedNodeBranch to directly encode left/right hashes and counters instead of using an intermediate children hash

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
SparseMerkleSumTreeTest.java Updated test assertions to use new simplified API methods (getValue(), getRootHash(), getData())
TokenSplitBuilder.java Updated to access root value and hash through new direct methods instead of nested object access
SplitMintReason.java Simplified coin tree verification by accessing value directly; removed unused Branch import
MintTransactionReasonJson.java Cleaned up unused imports related to removed serialization classes
SparseMerkleSumTreeRootNode.java Major refactoring: replaced Root object with direct hash/value access, updated path generation logic to use flattened structure
SparseMerkleSumTreePathStepJson.java Deleted - JSON serialization now handled by simpler structure
SparseMerkleSumTreePathStepBranchJson.java Deleted - Branch class removed from API
SparseMerkleSumTreePathStep.java Simplified by removing Branch inner class and using direct fields for data and value
SparseMerkleSumTreePath.java Replaced Root field with direct DataHash; updated verification algorithm to work with new structure
FinalizedNodeBranch.java Updated hashing to encode left/right branches directly instead of computing intermediate children hash
SparseMerkleTreeRootNode.java Removed unused path field that was always set to the same value
UnicitySealHashMatchesWithRootHashRule.java Reordered imports for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

return List.of(
new SparseMerkleSumTreePathStep(branch.getPath(), siblingBranch,
(FinalizedNodeBranch) branch));
ArrayList<SparseMerkleSumTreePathStep> list = new ArrayList<>(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor neatpick, usually type definition is an interface or "var": List<SparseMerkleSumTreePathStep> list = new ArrayList<> or var list = new ArrayList<>. the latter is ok since target is java11

#35 Add isMinted and isStateSpent methods in transition client
@b3y0urs3lf b3y0urs3lf merged commit 230c487 into main Nov 19, 2025
1 check passed
@b3y0urs3lf b3y0urs3lf deleted the issue-29 branch November 19, 2025 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants